from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search

# 创建一个 Elasticsearch 客户端实例，设置账号密码
es = Elasticsearch(
    [{'host': '10.8.207.214', 'port': 9200, 'scheme':'http'}],
    http_auth=("elastic", "infini_rag_flow")
)

# 测试连接
# info = es.info()
# print(info)

# 查看有哪些索引
print("start ---")
# response = es.cat.indices(format="json")
# print(response)
# for index in response:
#     print(index['index'])

# 查看索引下的文档
index_name = "ragflow_b460ea1239eb11ef8b300242ac130002"
documents = es.search(index=index_name, query={"match_all": {}}, size=100)

# 打印查询结果
for hit in documents['hits']['hits']:
    print(hit['_source'])